home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mcomm557.zip / ZCMPLR.C < prev    next >
C/C++ Source or Header  |  1993-09-11  |  10KB  |  262 lines

  1.  
  2. /*/////////////////////////////////////////////////////////////////////
  3. //                                                                   //
  4. //                                                                   //
  5. //  ZCMPLR.C -- compiler specific functions                          //
  6. //                                                                   //
  7. //   (c) 1991, Mike Dumdei, 6 Holly Lane, Texarkana TX, 75503        //
  8. //                                                                   //
  9. //////////////////////////////////////////////////////////////////// */
  10. #ifndef __TURBOC__          /* defined by Turbo C compiler */
  11.   #ifndef __ZTC__           /* defined by Zortech C compiler */
  12.     #define __MSC__         /* assume Microsoft C if not TC or ZTC */
  13.   #endif
  14. #endif
  15.  
  16. /*/////////////////////////////////////////////////////////////////
  17. //                                                               //
  18. //                                                               //
  19. //      Microsoft C  /  Quick C                                  //
  20. //                                                               //
  21. //                                                               //
  22. //////////////////////////////////////////////////////////////// */
  23. #ifdef __MSC__
  24.  
  25. #include <dos.h>
  26. /*/////////////////////////////////////////////////////////
  27. //  DosFindFirst -- find file (1st instance)             //
  28. //////////////////////////////////////////////////:disk:/*/
  29. int DosFindFirst(char *pathname, int atrib, struct find_t *fstruc)
  30. {
  31.     return (_dos_findfirst(pathname, atrib, fstruc));
  32. }
  33.  
  34. /*/////////////////////////////////////////////////////////
  35. //  DosFindNext -- find file (except 1st instance)       //
  36. //////////////////////////////////////////////////:disk:/*/
  37. int DosFindNext(struct find_t *fstruc)
  38. {
  39.     return (_dos_findnext(fstruc));
  40. }
  41.  
  42. /*/////////////////////////////////////////////////////////
  43. //  DosGetDiskFree -- gets free space left on disk       //
  44. //////////////////////////////////////////////////:disk:/*/
  45. long DosGetDiskFree(int drive)
  46. {
  47.     struct diskfree_t spc;
  48.     _dos_getdiskfree(drive, &spc);
  49.     return ((long)spc.avail_clusters * (long)spc.sectors_per_cluster *
  50.      (long)spc.bytes_per_sector);
  51. }
  52.  
  53. /*/////////////////////////////////////////////////////////
  54. //  DosSetFileTime -- set file date/time                 //
  55. //////////////////////////////////////////////////:disk:/*/
  56. int DosSetFileTime(int handle, unsigned date, unsigned time)
  57. {
  58.     return (_dos_setftime(handle, date, time));
  59. }
  60.  
  61. /*/////////////////////////////////////////////////////////
  62. //  DosSetFileAttr -- set file attribute                 //
  63. //////////////////////////////////////////////////:disk:/*/
  64. int DosSetFileAttr(char *path, unsigned attrib)
  65. {
  66.     return (_dos_setfileattr(path, attrib));
  67. }
  68. #endif
  69.  
  70.  
  71. /*/////////////////////////////////////////////////////////////////
  72. //                                                               //
  73. //                                                               //
  74. //      Turbo C  /  Turbo C++                                    //
  75. //                                                               //
  76. //                                                               //
  77. //////////////////////////////////////////////////////////////// */
  78. #ifdef __TURBOC__
  79.  
  80. #include <dos.h>
  81. #include <dir.h>
  82. #include <io.h>
  83.  
  84. #if __TURBOC__ >= 0x0410
  85.  #include <bios.h>
  86. #else
  87. /*/////////////////////////////////////////////////////////
  88. //  _bios_keybrd --  link to Turbo C/C++ bios key        //
  89. /////////////////////////////////////////////////////////*/
  90. int _bios_keybrd(int flag)
  91. {
  92.     return bioskey(flag);
  93. }
  94. #endif
  95.  
  96. /*/////////////////////////////////////////////////////////
  97. //  DosFindFirst -- find file (1st instance)             //
  98. //////////////////////////////////////////////////:disk:/*/
  99. int DosFindFirst(char *pathname, int atrib, struct ffblk *fstruc)
  100. {
  101.     return (findfirst(pathname, fstruc, atrib));
  102. }
  103.  
  104. /*/////////////////////////////////////////////////////////
  105. //  DosFindNext -- find file (except 1st instance)       //
  106. //////////////////////////////////////////////////:disk:/*/
  107. int DosFindNext(struct ffblk *fstruc)
  108. {
  109.     return (findnext(fstruc));
  110. }
  111.  
  112. /*/////////////////////////////////////////////////////////
  113. //  DosGetDiskFree -- gets free space left on disk       //
  114. //////////////////////////////////////////////////:disk:/*/
  115. long DosGetDiskFree(int drive)
  116. {
  117.     struct dfree spc;
  118.     getdfree(drive, &spc);
  119.     return ((long)spc.df_avail * (long)spc.df_sclus * (long)spc.df_bsec);
  120. }
  121.  
  122. /*/////////////////////////////////////////////////////////
  123. //  DosSetFileTime -- set file date/time                 //
  124. //////////////////////////////////////////////////:disk:/*/
  125. int DosSetFileTime(int handle, unsigned date, unsigned time)
  126. {
  127.     unsigned long ftim = ((unsigned long)date << 16) | (unsigned long)time;
  128.     return (setftime(handle, (struct ftime *)&ftim));
  129. }
  130.  
  131. /*/////////////////////////////////////////////////////////
  132. //  DosSetFileAttr -- set file attribute                 //
  133. //                                                       //
  134. //   Older versions of TURBO C libraries (TC++ 1.00 for  //
  135. //  sure) do not have the _dos_setfileattr function so   //
  136. //  the call to it is #if'd out.  The defined version    //
  137. //  (0x0400) corresponds to BC++ 3.0 which does have the //
  138. //  _dos_setfileattr function.  Probably some versions   //
  139. //  earlier than 4.0 do too but didn't have them to find //
  140. //  out.  It is only used if an undocumented switch is   //
  141. //  enabled so you probably will never miss it.          //
  142. //////////////////////////////////////////////////:disk:/*/
  143. int DosSetFileAttr(char *path, unsigned attrib)
  144. {
  145.   #if __TURBOC__ >= 0x0400
  146.     return (_dos_setfileattr(path, attrib));
  147.   #else
  148.     return 0;
  149.   #endif
  150. }
  151. #endif
  152.  
  153.  
  154. /*/////////////////////////////////////////////////////////////////
  155. //                                                               //
  156. //                                                               //
  157. //      Zortech C  /  Zortech C++                                //
  158. //                                                               //
  159. //                                                               //
  160. //////////////////////////////////////////////////////////////// */
  161. #ifdef __ZTC__
  162.  
  163. #define MSDOS 1
  164. #include <dos.h>
  165. long timezone = 0L;
  166.  
  167. /*/////////////////////////////////////////////////////////
  168. //  DosFindFirst -- find file (1st instance)             //
  169. //////////////////////////////////////////////////:disk: */
  170. int DosFindFirst(char *pathname, int atrib, struct find_t *fstruc)
  171. {
  172.     return (_dos_findfirst(pathname, atrib, fstruc));
  173. }
  174.  
  175. /*/////////////////////////////////////////////////////////
  176. //  DosFindNext -- find file (except 1st instance)       //
  177. //////////////////////////////////////////////////:disk: */
  178. int DosFindNext(struct find_t *fstruc)
  179. {
  180.     return (_dos_findnext(fstruc));
  181. }
  182.  
  183. /*/////////////////////////////////////////////////////////
  184. //  DosGetDiskFree -- gets free space left on disk       //
  185. //////////////////////////////////////////////////:disk: */
  186. long DosGetDiskFree(int drive)
  187. {
  188.     return (dos_getdiskfreespace(drive));
  189. }
  190.  
  191. /*/////////////////////////////////////////////////////////
  192. //  DosSetFileTime -- set file date/time                 //
  193. //////////////////////////////////////////////////:disk: */
  194. int DosSetFileTime(int handle, unsigned date, unsigned time)
  195. {
  196.     return (dos_setftime(handle, date, time));
  197. }
  198.  
  199. /*/////////////////////////////////////////////////////////
  200. //  DosSetFileAttr -- set file attribute                 //
  201. //////////////////////////////////////////////////:disk: */
  202. int DosSetFileAttr(char *path, unsigned attrib)
  203. {
  204.     return (dos_setfileattr(path, attrib));
  205. }
  206. #endif
  207.  
  208.  
  209. /*/////////////////////////////////////////////////////////////////////
  210. //                                                                   //
  211. //  The following math functions were added in TXZM version 2.15 in